using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Media;
using System.Text;
using System.Windows.Forms;
using NWN2Toolset;
using NWN2Toolset.Plugins;
using NWN2Toolset.NWN2.Views;
using TD.SandBar;


namespace Ambience_Pack
{
    public class AmbiencePack : INWN2Plugin
    {        
        private MenuButtonItem m_cMenuItem;
        private Prefs m_Prefs = new Prefs ();
        private AudioManager audio = new AudioManager ();
        private static bool[] keyPressed = new bool [1];

        private void KeyDownHandler (object obj, KeyEventArgs eArgs) {
            if (eArgs.KeyData == AirbrushPlugin.PreferenceManager.PluginPreferences.SmoothMode && keyPressed[0] == false) {
                audio.LoadFilesInFolder ("Airbrush Plugin\\Smooth Mode");
                keyPressed[0] = true;
            }
        }

        private void KeyUpHandler (object obj, KeyEventArgs eArgs) {
            if (eArgs.KeyData == AirbrushPlugin.PreferenceManager.PluginPreferences.SmoothMode && keyPressed[0] == true) {
                keyPressed[0] = false;
            }
        }

        private void LaunchPlugin (object sender, EventArgs e) {
        }

        public void Load (INWN2PluginHost cHost) {
        }

        public void Shutdown (INWN2PluginHost cHost) {
        }

        public void Startup (INWN2PluginHost cHost) {
            this.m_cMenuItem = cHost.GetMenuForPlugin (this);
            this.m_cMenuItem.Activate += new EventHandler (this.LaunchPlugin);
            this.m_cMenuItem.Visible = false;
            NWN2ToolsetMainForm.App.KeyPreview = true;
            NWN2ToolsetMainForm.App.KeyDown += new KeyEventHandler (KeyDownHandler);
            NWN2ToolsetMainForm.App.KeyUp += new KeyEventHandler (KeyUpHandler);

            audio.LoadFilesInFolder ("Startup");
        }

        public void Unload (INWN2PluginHost cHost) {
        }

        // Properties
        public string DisplayName {
            get {
                return "Ambience Pack";
            }
        }

        public string MenuName {
            get {
                return "Ambience Pack";
            }
        }

        public string Name {
            get {
                return "AmbiencePack";
            }
        }

        public MenuButtonItem PluginMenuItem {
            get {
                return this.m_cMenuItem;
            }
        }

        public object Preferences {
            get {
                return this.m_Prefs;
            }
            set {
                this.m_Prefs = (Prefs) value;
            }
        }
    }
}
